package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Zproductcategory {
    private int pcId;
    private String pcName;
    private Integer pcFatherid;
    private Integer pcLevel;
    private Collection<Zproduct> zproductsByPcId;
    private Zproductbrand zproductbrandByPdId;

   /* private Collection<Zproductmodelmiddle> middle;*/

    @Id
    @Column(name = "pc_id")
    public int getPcId() {
        return pcId;
    }

    public void setPcId(int pcId) {
        this.pcId = pcId;
    }

    @Basic
    @Column(name = "pc_name")
    public String getPcName() {
        return pcName;
    }

    public void setPcName(String pcName) {
        this.pcName = pcName;
    }

    @Basic
    @Column(name = "pc_fatherid")
    public Integer getPcFatherid() {
        return pcFatherid;
    }

    public void setPcFatherid(Integer pcFatherid) {
        this.pcFatherid = pcFatherid;
    }

    @Basic
    @Column(name = "pc_level")
    public Integer getPcLevel() {
        return pcLevel;
    }

    public void setPcLevel(Integer pcLevel) {
        this.pcLevel = pcLevel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Zproductcategory that = (Zproductcategory) o;
        return pcId == that.pcId &&
                Objects.equals(pcName, that.pcName) &&
                Objects.equals(pcFatherid, that.pcFatherid) &&
                Objects.equals(pcLevel, that.pcLevel);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pcId, pcName, pcFatherid, pcLevel);
    }

    @OneToMany(mappedBy = "zproductcategoryByPcId")
    public Collection<Zproduct> getZproductsByPcId() {
        return zproductsByPcId;
    }

    public void setZproductsByPcId(Collection<Zproduct> zproductsByPcId) {
        this.zproductsByPcId = zproductsByPcId;
    }

    @ManyToOne
    @JoinColumn(name = "pd_id", referencedColumnName = "pd_id")
    public Zproductbrand getZproductbrandByPdId() {
        return zproductbrandByPdId;
    }

    public void setZproductbrandByPdId(Zproductbrand zproductbrandByPdId) {
        this.zproductbrandByPdId = zproductbrandByPdId;
    }

   /* @OneToMany(mappedBy = "middle")
    public Collection<Zproductmodelmiddle> getMiddle() {
        return middle;
    }

    public void setMiddle(Collection<Zproductmodelmiddle> middle) {
        this.middle = middle;
    }*/
}
